use tokio::task;

async fn task(runtime: u64) {
    println!("bg task {} begin", runtime);
    std::thread::sleep(std::time::Duration::from_secs(runtime));
    println!("bg task {} end", runtime);
}

#[tokio::main]
async fn main() {


    let ids = vec![3,2,1];
    let mut jobs = Vec::with_capacity(ids.len());
    for id in ids {
        jobs.push(task::spawn(task(id)));
    }
    println!("task begin");
    for job in jobs  {
        job.await;
    }
    println!("main end");

}